package com.b2b2c.store.single.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.b2b2c.store.single.entity.StoreEvaluate;
import com.b2b2c.store.single.logic.StoreEvaluateLogic;
import com.b2b2c.store.single.service.IStoreEvaluateService;
import com.b2b2c.until.AjaxMap;
import com.b2b2c.until.IsLogin;


/**
 * 店铺首页
 * @author Administrator
 */
@RestController
public class IndexController {
	
	@Autowired
	private HttpServletRequest req;
	
	@Resource
	private RedisTemplate<String, StoreEvaluate> redisTemplate;
	/**
	 * 首页接口
	 * @return
	 */
	@RequestMapping(value="/Index/index", method = RequestMethod.POST)
	public Map<String, ?> index()
	{
		if (!IsLogin.checkLogin(this.req)) {
			return AjaxMap.getInstance("未登录").getAjaxResultMessage();
		}
		
		IStoreEvaluateService<StoreEvaluate> storeEvaluate = new StoreEvaluateLogic(req);
		
		StoreEvaluate evalute = storeEvaluate.getScore(redisTemplate);
		
		
		return AjaxMap.getInstance(evalute).getAjaxResultByMap();
	}
	
}
